﻿using MediatR;
using SheepStorage.API.Application.Command.BodySizeCommand;
using SheepStorage.API.Application.Command.BuildingManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.BodySizeHandler
{
    public class BodySizeCreateHandler : IRequestHandler<BodySizeCreateCommand, Results<int>>
    {

        private readonly IBodySizeService service;

        public BodySizeCreateHandler(IBodySizeService service)
        {   
            this.service = service;
        }


        public async Task<Results<int>> Handle(BodySizeCreateCommand request, CancellationToken cancellationToken)
        {
            var entity = new BodySize
            {
                BodySizeId = request.BodySizeId,
                OverBit=request.OverBit,
          
                CheckDate=request.CheckDate,
                SheepType=request.SheepType,
                BodySex=request.BodySex==1?true:false,
          
                BodyHeight=request.BodyHeight,
                BodyLength=request.BodyLength,
                BodyThorax=request.BodyThorax,
                BodyFoot=request.BodyFoot,
                BodyScrotum=request.BodyScrotum,
                BodyBackWeight=request.BodyBackWeight,
                BodyEyeArea=request.BodyEyeArea,
                BodyEyeWeight=request.BodyEyeWeight,
                AddTime=DateTime.Now,
                AddName="侯佳",
                IsDel=0,

            };
            var list = await service.AddBodySize(entity);
            return Results<int>.DataResult(list);
        }
    }
}
